
<script setup>
import Header from '@/components/Header.vue';
import { computed, ref } from 'vue';
import { useRouter } from 'vue-router';
import titles from '../../components/titles.vue'

let Name = ref('ZHI XIAOBAO')
let Gender = ref('Male')
let DateOfBirth = ref('')
let StartDate = ref('')
let CompletionDate = ref('')
let HigherEducationInstitution = ref('Lanzhou University')
let Major = ref('Civil Engineering')
let LengthOfProgram = ref('2.5 years')
let EducationLevel = ref('Associate Degree')
let TypeOfEducation = ref('Online Education')
let Status = ref('Graduated')
let CertificateNo = ref('1045 9720 0905 0037 62')
let PresidentName = ref('')
let router = useRouter();

let canSubmit = computed(() => {
    return  Name.value.trim() !== '' &&
            Gender.value.trim() !== '' &&
            DateOfBirth.value.trim() !== '' &&
            StartDate.value.trim() !== '' &&
            CompletionDate.value.trim() !== '' &&
            HigherEducationInstitution.value.trim() !== '' &&
            Major.value.trim() !== '' &&
            LengthOfProgram.value.trim() !== '' &&
            EducationLevel.value.trim() !== '' &&
            TypeOfEducation.value.trim() !== '' &&
            Status.value.trim() !== '' &&
            CertificateNo.value.trim() !== '';
});

let input = ref([])
let handleSubmit = () =>{ 
    input.value = localStorage.getItem('formData')
    if(input.value){     
        input.value = JSON.parse(input.value)
    }else{
        input.value=[]
    }
       
    let formData = {
        Name: Name.value,
        Gender: Gender.value,
        DateOfBirth: DateOfBirth.value,
        StartDate: StartDate.value,
        CompletionDate: CompletionDate.value,
        HigherEducationInstitution: HigherEducationInstitution.value,
        Major: Major.value,
        LengthOfProgram: LengthOfProgram.value,
        EducationLevel: EducationLevel.value,
        TypeOfEducation:TypeOfEducation.value,
        Status: Status.value,
        CertificateNo: CertificateNo.value,
        PresidentName: PresidentName.value,
        ApplicationID: 'ZA'+new Date().getTime(),
        ApplicationDate: new Date().toLocaleDateString(),
        CertificateType: 'University Certificates',
        Statuss: 'Verified',
        id: input.value.length,    
    }
    input.value.push(formData)
    localStorage.setItem('formData', JSON.stringify(input.value));
    router.push('/Details/'+(input.value.length-1))
}

</script>



<template>
    <Header></Header>
    <div class="content">
        <titles :title="'Apply Credentials / UniversityCertificates'"></titles>
        <div class="box">
            <div class="left-box">
                <div>
                    <p>
                        <RouterLink to="/MyCredentials">My Credentials</RouterLink>
                    </p>
                </div>
                <div class="left-box-active">
                    <p>
                        <RouterLink to="/ApplyCredentials">Apply Credentials</RouterLink>
                    </p>
                </div>
                <div>
                    <p>
                        <RouterLink to="/AccountInformation">Account Information</RouterLink>
                    </p>
                </div>
            </div>
            <div class="right-box">
                <div class="right-box-title">
                    <p class="title">Upload your documents</p>
                    <p class="title-t"><b>original University Certificates</b></p>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Name <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <input type="text" placeholder="Enter Name" v-model="Name" />
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!Name">Please input Name!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Gender <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <select v-model="Gender">
                                    <option>Male</option>
                                    <option>Female</option>
                                </select>
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!Gender">Please input!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Date of Birth <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <input type="date" value="1995-11-23" v-model="DateOfBirth">
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!DateOfBirth">Please input!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Start Date <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <input type="date" value="2017-04-01" v-model="StartDate">
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!StartDate">Please input!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Completion Date <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <input type="date" value="2019-09-30" v-model="CompletionDate">
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!CompletionDate">Please input!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Higher Education Institution <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <input type="text" placeholder="Enter Hight Education Institution" v-model="HigherEducationInstitution" />
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!HigherEducationInstitution">Please inputHigher Education Institution !</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Major <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <input type="text" placeholder="Enter Major" v-model="Major" />
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!Major">Please input Major!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Length of Program <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <select v-model="LengthOfProgram">
                                    <option>2 years</option>
                                    <option>2.5 years</option>
                                    <option>3 years</option>
                                    <option>3.5 years</option>
                                    <option>4 years</option>
                                    <option>4.5 years</option>
                                    <option>5 years</option>
                                    <option>7 years</option>
                                    <option>9 years</option>
                                </select>
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!LengthOfProgram">Please input!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Education Level <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <select v-model="EducationLevel">
                                    <option>Associate Degree</option>
                                    <option>Night university, TV university, Correspondence university, genera class
                                    </option>
                                </select>
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!EducationLevel">Please input!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Type of Education <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <select v-model="TypeOfEducation">
                                    <option>Online Education</option>
                                    <option>Part-time</option>
                                </select>
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!TypeOfEducation">Please input!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Status <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <select v-model="Status">
                                    <option>Graduated</option>
                                    <option>Completion</option>
                                </select>
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!Status">Please input!</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>Certificate No. <span>*</span></p>
                            </div>
                            <div class="right-box-title-input-right">
                                <input type="text" placeholder="Enter Certificate No." v-model="CertificateNo" />
                            </div>
                        </div>
                        <div class="right-box-title-zhuyi" v-if="!CertificateNo">Please input Certificate No. !</div>
                        <div class="right-box-input">
                            <div class="right-box-title-input-left">
                                <p>President Name</p>
                            </div>
                            <div class="right-box-title-input-right">
                                <input type="text" placeholder="Enter President Name" v-model="PresidentName">
                            </div>
                        </div>
                        <!-- <div class="right-box-title-bottom">
                            <div class="right-box-title-bottom-t">
                                <div class="title-t"><b>Scanned copy of the original university certificate</b>
                                    <span>*</span>
                                </div>
                            </div>
                            <div class="right-box-title-bottom-b">
                                <div class="btn_red right-box-title-bottom-b-left">Upload</div>
                                <div class="right-box-title-bottom-b-between">jpg/png, 5mb max</div>
                                <div class="right-box-title-bottom-b-right">
                                    <img src="../../assets/img/xiaoyanjing.svg" alt="">
                                    Sample
                                </div>
                            </div>
                        </div>
                        <div class="right-box-title-bottom">
                            <div class="right-box-title-bottom-t">
                                <div class="title-t"><b>Scanned copy of the original university certificate</b>
                                    <span>*</span>
                                </div>
                            </div>
                            <div class="right-box-title-bottom-b">
                                <div class="btn_red right-box-title-bottom-b-left">Upload</div>
                                <div class="right-box-title-bottom-b-between">jpg/png, 5mb max</div>
                                <div class="right-box-title-bottom-b-right">
                                    <img src="../../assets/img/xiaoyanjing.svg" alt="">
                                    Sample
                                </div>
                            </div>
                        </div> -->


                        <div class="right-box-bottom">
                           
                            <button :disabled="!canSubmit" :class="{ 'active-button': canSubmit }" @click="handleSubmit" 
                                type="submit">Next</button>
                        </div>
                </div>


            </div>


        </div>
    </div>
</template>
<style scoped>
.content {
    width: 1100px;
    height: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
    margin-top: 100px;

    .title {
        display: flex;
        color: #1F2930;
        font-size: 20px;
        font-weight: 600;
        line-height: 30px;

        p {
            margin: 0 10px 20px 0;
        }

        .title-home {
            color: #0F094C;
        }
    }

    .box {
        display: flex;

        .left-box {
            display: flex;
            flex-direction: column;
            border: 1px solid #EFEFEF;
            width: 271px;
            margin: 0 20px 0 0;

            .left-box-active {
                p {
                    color: #EC535B;
                    font-weight: 700;
                    font-size: 18px;
                }

                background-color: #FFECEC;
            }

            p {
                margin: 20px 0 20px 10px;
                color: #1F2930;
                font-size: 18px;
                font-weight: 400;
            }
        }

        .right-box {
            border: 1px solid #EFEFEF;
            width: 900px;

            .right-box-title {
                margin: 20px;

                .title-t {
                    margin: 20px 0 20px 0;
                    font-size: 16px;
                    font-weight: 500;
                }

                .right-box-title-zhuyi {
                    color: #EC535B;
                    font-size: 14px;
                }

                .right-box-input {
                    display: flex;
                    align-items: center;
                    width: 474px;
                    height: 44px;
                    justify-content: space-between;
                    border: 1px solid #EFEFEF;
                    border-radius: 6px;
                    margin-top: 20px;

                    .right-box-title-input-left {
                        margin-left: 20px;

                        p {
                            font-size: 16px;
                            font-weight: 500;
                            color: #9A9A9A;

                            span {
                                color: red;
                            }
                        }
                    }

                    .right-box-title-input-right {
                        width: 200px;

                        input {
                            width: 200px;
                            height: 30px;
                            font-size: 14px;
                            border: none;
                            outline: none;
                            background-color: rgba(0, 0, 0, 0);

                        }

                        select {
                            width: 200px;
                            height: 30px;
                            font-size: 14px;
                            border: none;
                            background-color: rgba(0, 0, 0, 0);
                        }
                    }
                }

                .right-box-title-bottom {
                    .right-box-title-bottom-t {
                        span {
                            color: red;
                        }
                    }

                    .right-box-title-bottom-b {
                        display: flex;
                        align-items: center;

                        .right-box-title-bottom-b-left {
                            width: 126px;
                            height: 44px;
                            display: flex;
                            justify-content: center;
                            align-items: center;
                            border-radius: 6px;
                            font-size: 18px;

                        }

                        .right-box-title-bottom-b-between {
                            margin: 0 50px;
                            font-size: 14px;
                            color: #9A9A9A;
                        }

                        .right-box-title-bottom-b-right {
                            display: flex;
                            align-items: center;

                            img {
                                margin-right: 10px;
                            }
                        }
                    }

                }
                .right-box-bottom {
            display: flex;
            justify-content: end;

            .active-button {
                background-color: #EC535B;
                color: #ffffff;
            }

            button {
                width: 149px;
                height: 44px;
                margin: 50px 50px 0 0;
                border: none;
                border-radius: 6px;
                cursor: pointer;

            }
        }


            }

        }

        
    }
}
</style>